//
//  EWAddBusinessCell.m
//  haveSomethingToEat
//
//  Created by 陈 宁权 on 2017/6/30.
//  Copyright © 2017年 陈 宁权. All rights reserved.
//

#import "EWAddBusinessCell.h"

@implementation EWAddBusinessCell

+ (instancetype)cellWithTableView:(UITableView *)tableView
{
    static NSString *identifier = @"EWAddBusinessCell";
    EWAddBusinessCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (cell == nil) {
        cell = [[EWAddBusinessCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
    }
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setupChildViews];
        self.backgroundColor = [UIColor clearColor];
    }
    return self;
}

- (void)setupChildViews
{
    UIImage *image = [[UIImage imageNamed:@"add_business"] scaleToSize:CGSizeMake(15, 15)];
    UIImageView *addLogo = [[UIImageView alloc] initWithImage:image];
    addLogo.contentMode = UIViewContentModeScaleToFill;
    [self addSubview:addLogo];
    
    UILabel *addBusinessLabel = [[UILabel alloc] init];
    addBusinessLabel.text = @"添加更多商家";
    addBusinessLabel.font = [UIFont systemFontOfSize:12];
    addBusinessLabel.textColor = BASE_COLOR;
    [self addSubview:addBusinessLabel];
    
    UIView *bottomView = [[UIView alloc] init];
    bottomView.backgroundColor = [UIColor colorWithRed:0.92 green:0.92 blue:0.95 alpha:1.00];
    [self addSubview:bottomView];
    
    [addLogo mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self).offset(10);
        make.centerX.equalTo(self).offset(-40);
        make.height.offset(15);
        make.width.offset(15);
    }];
    
    [addBusinessLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(addLogo);
        make.left.equalTo(addLogo.mas_right).offset(5);
        make.height.offset(20);
        make.width.offset(80);
    }];
    
    [bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(addBusinessLabel.mas_bottom).offset(10);
        make.left.equalTo(self);
        make.right.equalTo(self);
        make.height.offset(25);
    }];
}

@end
